package com.flynn.rock.system.service.impl;

import com.flynn.rock.system.convert.AbstractDeptConvert;
import com.flynn.rock.system.entity.SysDeptEntity;
import com.flynn.rock.system.model.vo.DeptListVo;
import com.flynn.rock.system.repository.SysDeptRepository;
import com.flynn.rock.system.service.SysDeptService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysDeptServiceImpl implements SysDeptService {

    @Resource
    private SysDeptRepository sysDeptRepository;

    @Override
    public List<DeptListVo> getDeptList() {
        List<SysDeptEntity> deptEntities = sysDeptRepository.findAll();
        return deptEntities.stream().map(AbstractDeptConvert.INSTANCE::toDeptListVo).toList();
    }
}
